package com.gyg.service.impl;

import com.gyg.dao.IFileDao;
import com.gyg.entity.File;
import com.gyg.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <des>
 *
 * <des>
 *
 * @create Date 2021-11-03
 **/
@Service
public class FileServiceImpl implements IFileService {
    @Autowired
    IFileDao iFileDao;

    @Override
    public Integer save(File file) {
        Map<String,Object> param = new HashMap<>();
        param.put("fileName",file.getFileName());
        param.put("description",file.getDescription());
        param.put("url",file.getUrl());
        param.put("created",file.getCreated());
        return iFileDao.save(param);
    }

    @Override
    public List<File> list() {
        return iFileDao.list();
    }

    @Override
    public Integer update(File file) {
        Map<String,Object> param = new HashMap<>();
        param.put("id",file.getId());
        param.put("fileName",file.getFileName());
        param.put("description",file.getDescription());
        return iFileDao.update(param);
    }

    @Override
    public Integer delete(Integer id) {
        return iFileDao.delete(id);
    }
}
